<template>
  <el-table
    :data="tableData"
    border
    style="width: 100%"
  >
    <el-table-column type="index" label="序号" min-width="40" align="center"></el-table-column>
    <el-table-column
      prop="qid"
      label="题目ID"
      width="80"
      align="center"
    />
    <el-table-column
      prop="qtid"
      label="题目类型ID"
      width="100"
      align="center"
    />
    <el-table-column
      prop="questionName"
      label="题目标题"
      width="200"
      align="center"
    />
    <el-table-column
      prop="questionContent"
      label="题目内容"
      width="300"
      align="center"
    />
    <el-table-column
      prop="url"
      label="题目文件"
      width="100"
      align="center"
    >
      <template slot-scope="scope">
        {{ scope.row.url ? scope.row.url :'暂无' }}
      </template>
    </el-table-column>
    <el-table-column
      prop="addingTime"
      label="上传时间"
      width="150"
    />
    <el-table-column
      prop="tid"
      label="教师ID"
      width="100"
    />
    <el-table-column
      fixed="right"
      label="操作"
      width="100"
    >
      <template slot-scope="scope">
        <el-button type="text" size="small" @click="handleClick(scope.$index)">去完成</el-button>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
import { getAllWorkList } from '../../api/work'

export default {
  components: {},
  data() {
    return {
      tableData: [],
      page: {
        pageNum: 1,
        pageSize: 10,
        totalPage: 0,
        totalSize: 0
      }
    }
  },
  created() {
   this.getList()
  },
  methods: {
    getList() {
      getAllWorkList({
        pageNum: this.page.pageNum,
        pageSize: this.page.pageSize
      }).then(res => {
        this.tableData = res.data.list
        this.page = res.data.page
      }).catch(err => {
        this.$message.error('请求失败！')
      })
    },
    handleClick(index) {
      const qid = this.tableData[index].qid
      const tid = this.tableData[index].tid
      this.$router.push({ path: '/homework/workDetail', query: { qid: qid,tid:tid }})
    }
  }
}
</script>
<style scoped></style>
